/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * borrador.java
 *
 * Created on Oct 26, 2011, 6:07:31 PM
 */

package visual.Almacenamiento;

import bentity.beProducto;
import blogic.blHelper;
import blogic.blPallet;
import blogic.blRack;
import blogic.blUbicacion;
import java.sql.Date;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import visual.Seguridad.visualHelper;
import bentity.beUsuario;
import blogic.blLog;

/**
 *
 * @author cesar
 */
public class pnfReubicarProducto extends javax.swing.JPanel {
    public static final int CONST1 =1;
    public static final int CONST2 = 2;
    public int idubi = -1;
    public int ubiAnt = -1;
    public int tipoPallet = -1;
    public int tipoProd = -1;
    private beUsuario usuario = null;

    /** Creates new form borrador */
    public pnfReubicarProducto(beUsuario usuario) {
        initComponents();
        this.usuario = usuario;
        this.txtCodigo.setEnabled(false);
        this.txtFila.setEnabled(false);
        this.txtPiso.setEnabled(false);
        this.txtRack.setEnabled(false);
        this.txtUbicacion.setEnabled(false);

        this.txtFilaN.setEnabled(false);
        this.txtUbicacionN.setEnabled(false);
        this.txtPisoN.setEnabled(false);
        this.txtRackN.setEnabled(false);
        this.txtCodigo.setEnabled(false);
        this.btnBuscarUbiDisponiles.setEnabled(false);
        this.btnGuardar.setEnabled(false);
 
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel24 = new javax.swing.JLabel();
        pnlEliminarPallet = new javax.swing.JPanel();
        lblRack = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        txtDescripcion = new javax.swing.JTextArea();
        lblCodigo1 = new javax.swing.JLabel();
        txtCodPallet = new javax.swing.JTextField();
        lblCosto1 = new javax.swing.JLabel();
        rbnRack = new javax.swing.JRadioButton();
        rbnProducto = new javax.swing.JRadioButton();
        lblDescripcion = new javax.swing.JLabel();
        lblFecha = new javax.swing.JLabel();
        txtCodigo1 = new javax.swing.JTextField();
        txtCodRack = new javax.swing.JTextField();
        lblPallet = new javax.swing.JLabel();
        dtcFecha = new com.toedter.calendar.JDateChooser();
        btnBuscarRack = new javax.swing.JButton();
        btnBuscarPallet = new javax.swing.JButton();
        pnlEliminarPallet1 = new javax.swing.JPanel();
        lblRack1 = new javax.swing.JLabel();
        jScrollPane5 = new javax.swing.JScrollPane();
        txtDescripcion1 = new javax.swing.JTextArea();
        lblCodigo2 = new javax.swing.JLabel();
        txtCodPallet1 = new javax.swing.JTextField();
        lblCosto2 = new javax.swing.JLabel();
        rbnRack1 = new javax.swing.JRadioButton();
        rbnProducto1 = new javax.swing.JRadioButton();
        lblDescripcion1 = new javax.swing.JLabel();
        lblFecha1 = new javax.swing.JLabel();
        txtCodigo2 = new javax.swing.JTextField();
        txtCodRack1 = new javax.swing.JTextField();
        lblPallet1 = new javax.swing.JLabel();
        dtcFecha1 = new com.toedter.calendar.JDateChooser();
        btnBuscarRack1 = new javax.swing.JButton();
        btnBuscarPallet1 = new javax.swing.JButton();
        pnlEliminarPallet2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        txtFila = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        txtRack = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        txtPiso = new javax.swing.JTextField();
        txtUbicacion = new javax.swing.JTextField();
        lblCodigo = new javax.swing.JLabel();
        txtCodigo = new javax.swing.JTextField();
        btBuscar = new javax.swing.JButton();
        btnLimpiar = new javax.swing.JButton();
        pnlEliminarPallet3 = new javax.swing.JPanel();
        lblMotivo = new javax.swing.JLabel();
        lblFilaNueva = new javax.swing.JLabel();
        txtFilaN = new javax.swing.JTextField();
        txtRackN = new javax.swing.JTextField();
        lblUbiNueva = new javax.swing.JLabel();
        txtUbicacionN = new javax.swing.JTextField();
        txtPisoN = new javax.swing.JTextField();
        lblPiso = new javax.swing.JLabel();
        btnGuardar = new javax.swing.JButton();
        btnBuscarUbiDisponiles = new javax.swing.JButton();
        dtcFecha2 = new com.toedter.calendar.JDateChooser();
        lblRackNuevo = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        txtMotivo = new javax.swing.JTextArea();
        lblBusqFila = new javax.swing.JLabel();

        setFont(new java.awt.Font("Dialog", 0, 12));
        setLayout(null);

        jLabel24.setFont(new java.awt.Font("DejaVu Sans", 0, 36));
        jLabel24.setForeground(new java.awt.Color(0, 0, 0));
        jLabel24.setText("Reubicación de pallet");
        add(jLabel24);
        jLabel24.setBounds(280, 20, 388, 43);

        pnlEliminarPallet.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Datos de Incidencia", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 14), new java.awt.Color(0, 0, 0))); // NOI18N
        pnlEliminarPallet.setLayout(null);

        lblRack.setFont(new java.awt.Font("Dialog", 0, 12));
        lblRack.setForeground(new java.awt.Color(0, 0, 0));
        lblRack.setText("Rack");
        pnlEliminarPallet.add(lblRack);
        lblRack.setBounds(70, 250, 50, 15);

        txtDescripcion.setColumns(20);
        txtDescripcion.setRows(5);
        jScrollPane4.setViewportView(txtDescripcion);

        pnlEliminarPallet.add(jScrollPane4);
        jScrollPane4.setBounds(160, 80, 270, 100);

        lblCodigo1.setFont(new java.awt.Font("Dialog", 0, 12));
        lblCodigo1.setText("Codigo");
        pnlEliminarPallet.add(lblCodigo1);
        lblCodigo1.setBounds(70, 40, 43, 15);

        txtCodPallet.setEnabled(false);
        pnlEliminarPallet.add(txtCodPallet);
        txtCodPallet.setBounds(160, 290, 270, 28);

        lblCosto1.setFont(new java.awt.Font("Dialog", 0, 12));
        lblCosto1.setForeground(new java.awt.Color(0, 0, 0));
        lblCosto1.setText("Tipo");
        pnlEliminarPallet.add(lblCosto1);
        lblCosto1.setBounds(70, 200, 60, 20);

        rbnRack.setFont(new java.awt.Font("Dialog", 0, 12));
        rbnRack.setText("Por rack");
        rbnRack.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbnRackActionPerformed(evt);
            }
        });
        pnlEliminarPallet.add(rbnRack);
        rbnRack.setBounds(160, 200, 125, 24);

        rbnProducto.setFont(new java.awt.Font("Dialog", 0, 12));
        rbnProducto.setText("Por Pallet");
        rbnProducto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbnProductoActionPerformed(evt);
            }
        });
        pnlEliminarPallet.add(rbnProducto);
        rbnProducto.setBounds(370, 200, 86, 24);

        lblDescripcion.setFont(new java.awt.Font("Dialog", 0, 12));
        lblDescripcion.setForeground(new java.awt.Color(0, 0, 0));
        lblDescripcion.setText("Descripcion");
        pnlEliminarPallet.add(lblDescripcion);
        lblDescripcion.setBounds(70, 90, 73, 15);

        lblFecha.setFont(new java.awt.Font("Dialog", 0, 12));
        lblFecha.setForeground(new java.awt.Color(0, 0, 0));
        lblFecha.setText("Fecha");
        pnlEliminarPallet.add(lblFecha);
        lblFecha.setBounds(70, 340, 60, 30);

        txtCodigo1.setEnabled(false);
        pnlEliminarPallet.add(txtCodigo1);
        txtCodigo1.setBounds(160, 30, 270, 28);

        txtCodRack.setEnabled(false);
        pnlEliminarPallet.add(txtCodRack);
        txtCodRack.setBounds(160, 240, 270, 28);

        lblPallet.setFont(new java.awt.Font("Dialog", 0, 12));
        lblPallet.setForeground(new java.awt.Color(0, 0, 0));
        lblPallet.setText("Pallet");
        pnlEliminarPallet.add(lblPallet);
        lblPallet.setBounds(70, 290, 60, 30);
        pnlEliminarPallet.add(dtcFecha);
        dtcFecha.setBounds(160, 340, 300, 28);

        btnBuscarRack.setBackground(new java.awt.Color(240, 235, 226));
        btnBuscarRack.setFont(new java.awt.Font("Dialog", 0, 12));
        btnBuscarRack.setText("+");
        btnBuscarRack.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarRackActionPerformed(evt);
            }
        });
        pnlEliminarPallet.add(btnBuscarRack);
        btnBuscarRack.setBounds(440, 240, 30, 27);

        btnBuscarPallet.setBackground(new java.awt.Color(240, 235, 226));
        btnBuscarPallet.setFont(new java.awt.Font("Dialog", 0, 12));
        btnBuscarPallet.setText("+");
        btnBuscarPallet.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarPalletActionPerformed(evt);
            }
        });
        pnlEliminarPallet.add(btnBuscarPallet);
        btnBuscarPallet.setBounds(440, 290, 30, 27);

        add(pnlEliminarPallet);
        pnlEliminarPallet.setBounds(0, 0, 0, 0);

        pnlEliminarPallet1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Datos de Incidencia", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 14), new java.awt.Color(0, 0, 0))); // NOI18N
        pnlEliminarPallet1.setLayout(null);

        lblRack1.setFont(new java.awt.Font("Dialog", 0, 12));
        lblRack1.setForeground(new java.awt.Color(0, 0, 0));
        lblRack1.setText("Rack");
        pnlEliminarPallet1.add(lblRack1);
        lblRack1.setBounds(70, 250, 50, 15);

        txtDescripcion1.setColumns(20);
        txtDescripcion1.setRows(5);
        jScrollPane5.setViewportView(txtDescripcion1);

        pnlEliminarPallet1.add(jScrollPane5);
        jScrollPane5.setBounds(160, 80, 270, 100);

        lblCodigo2.setFont(new java.awt.Font("Dialog", 0, 12));
        lblCodigo2.setText("Codigo");
        pnlEliminarPallet1.add(lblCodigo2);
        lblCodigo2.setBounds(70, 40, 43, 15);

        txtCodPallet1.setEnabled(false);
        pnlEliminarPallet1.add(txtCodPallet1);
        txtCodPallet1.setBounds(160, 290, 270, 28);

        lblCosto2.setFont(new java.awt.Font("Dialog", 0, 12));
        lblCosto2.setForeground(new java.awt.Color(0, 0, 0));
        lblCosto2.setText("Tipo");
        pnlEliminarPallet1.add(lblCosto2);
        lblCosto2.setBounds(70, 200, 60, 20);

        rbnRack1.setFont(new java.awt.Font("Dialog", 0, 12));
        rbnRack1.setText("Por rack");
        rbnRack1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbnRack1ActionPerformed(evt);
            }
        });
        pnlEliminarPallet1.add(rbnRack1);
        rbnRack1.setBounds(160, 200, 125, 24);

        rbnProducto1.setFont(new java.awt.Font("Dialog", 0, 12));
        rbnProducto1.setText("Por Pallet");
        rbnProducto1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbnProducto1ActionPerformed(evt);
            }
        });
        pnlEliminarPallet1.add(rbnProducto1);
        rbnProducto1.setBounds(370, 200, 86, 24);

        lblDescripcion1.setFont(new java.awt.Font("Dialog", 0, 12));
        lblDescripcion1.setForeground(new java.awt.Color(0, 0, 0));
        lblDescripcion1.setText("Descripcion");
        pnlEliminarPallet1.add(lblDescripcion1);
        lblDescripcion1.setBounds(70, 90, 73, 15);

        lblFecha1.setFont(new java.awt.Font("Dialog", 0, 12));
        lblFecha1.setForeground(new java.awt.Color(0, 0, 0));
        lblFecha1.setText("Fecha");
        pnlEliminarPallet1.add(lblFecha1);
        lblFecha1.setBounds(70, 340, 60, 30);

        txtCodigo2.setEnabled(false);
        pnlEliminarPallet1.add(txtCodigo2);
        txtCodigo2.setBounds(160, 30, 270, 28);

        txtCodRack1.setEnabled(false);
        pnlEliminarPallet1.add(txtCodRack1);
        txtCodRack1.setBounds(160, 240, 270, 28);

        lblPallet1.setFont(new java.awt.Font("Dialog", 0, 12));
        lblPallet1.setForeground(new java.awt.Color(0, 0, 0));
        lblPallet1.setText("Pallet");
        pnlEliminarPallet1.add(lblPallet1);
        lblPallet1.setBounds(70, 290, 60, 30);
        pnlEliminarPallet1.add(dtcFecha1);
        dtcFecha1.setBounds(160, 340, 300, 28);

        btnBuscarRack1.setBackground(new java.awt.Color(240, 235, 226));
        btnBuscarRack1.setFont(new java.awt.Font("Dialog", 0, 12));
        btnBuscarRack1.setText("+");
        btnBuscarRack1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarRack1ActionPerformed(evt);
            }
        });
        pnlEliminarPallet1.add(btnBuscarRack1);
        btnBuscarRack1.setBounds(440, 240, 30, 27);

        btnBuscarPallet1.setBackground(new java.awt.Color(240, 235, 226));
        btnBuscarPallet1.setFont(new java.awt.Font("Dialog", 0, 12));
        btnBuscarPallet1.setText("+");
        btnBuscarPallet1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarPallet1ActionPerformed(evt);
            }
        });
        pnlEliminarPallet1.add(btnBuscarPallet1);
        btnBuscarPallet1.setBounds(440, 290, 30, 27);

        add(pnlEliminarPallet1);
        pnlEliminarPallet1.setBounds(0, 0, 0, 0);

        pnlEliminarPallet2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Busqueda Pallets", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 14), new java.awt.Color(0, 0, 0))); // NOI18N
        pnlEliminarPallet2.setLayout(null);

        jLabel1.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel1.setForeground(java.awt.Color.black);
        jLabel1.setText("Fila actual");
        pnlEliminarPallet2.add(jLabel1);
        jLabel1.setBounds(40, 40, 230, 15);

        txtFila.setEnabled(false);
        pnlEliminarPallet2.add(txtFila);
        txtFila.setBounds(170, 30, 134, 28);

        jLabel2.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel2.setForeground(java.awt.Color.black);
        jLabel2.setText("Bloque actual");
        pnlEliminarPallet2.add(jLabel2);
        jLabel2.setBounds(40, 80, 200, 15);

        txtRack.setEnabled(false);
        pnlEliminarPallet2.add(txtRack);
        txtRack.setBounds(170, 70, 134, 28);

        jLabel3.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel3.setForeground(java.awt.Color.black);
        jLabel3.setText("Piso actual");
        pnlEliminarPallet2.add(jLabel3);
        jLabel3.setBounds(40, 120, 170, 15);

        jLabel4.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel4.setForeground(java.awt.Color.black);
        jLabel4.setText("Columna actual");
        pnlEliminarPallet2.add(jLabel4);
        jLabel4.setBounds(500, 40, 170, 15);

        txtPiso.setEnabled(false);
        pnlEliminarPallet2.add(txtPiso);
        txtPiso.setBounds(170, 110, 134, 28);

        txtUbicacion.setEnabled(false);
        pnlEliminarPallet2.add(txtUbicacion);
        txtUbicacion.setBounds(650, 30, 134, 28);

        lblCodigo.setFont(new java.awt.Font("Dialog", 0, 12));
        lblCodigo.setForeground(java.awt.Color.black);
        lblCodigo.setText("Codigo");
        pnlEliminarPallet2.add(lblCodigo);
        lblCodigo.setBounds(500, 80, 120, 15);

        txtCodigo.setEnabled(false);
        pnlEliminarPallet2.add(txtCodigo);
        txtCodigo.setBounds(650, 70, 130, 28);

        btBuscar.setBackground(new java.awt.Color(240, 235, 236));
        btBuscar.setFont(new java.awt.Font("Dialog", 0, 12));
        btBuscar.setText("Buscar");
        btBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btBuscarActionPerformed(evt);
            }
        });
        pnlEliminarPallet2.add(btBuscar);
        btBuscar.setBounds(210, 160, 110, 27);

        btnLimpiar.setBackground(new java.awt.Color(240, 235, 236));
        btnLimpiar.setFont(new java.awt.Font("Dialog", 0, 12));
        btnLimpiar.setText("Limpiar");
        btnLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimpiarActionPerformed(evt);
            }
        });
        pnlEliminarPallet2.add(btnLimpiar);
        btnLimpiar.setBounds(500, 160, 110, 27);

        add(pnlEliminarPallet2);
        pnlEliminarPallet2.setBounds(50, 70, 850, 210);

        pnlEliminarPallet3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Posiciones Nuevas", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 14), new java.awt.Color(0, 0, 0))); // NOI18N
        pnlEliminarPallet3.setLayout(null);

        lblMotivo.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
        lblMotivo.setForeground(java.awt.Color.black);
        lblMotivo.setText("Motivo");
        pnlEliminarPallet3.add(lblMotivo);
        lblMotivo.setBounds(40, 120, 120, 15);

        lblFilaNueva.setFont(new java.awt.Font("Dialog", 0, 12));
        lblFilaNueva.setForeground(java.awt.Color.black);
        lblFilaNueva.setText("Fila nueva");
        pnlEliminarPallet3.add(lblFilaNueva);
        lblFilaNueva.setBounds(40, 40, 200, 15);

        txtFilaN.setEnabled(false);
        pnlEliminarPallet3.add(txtFilaN);
        txtFilaN.setBounds(170, 30, 140, 28);

        txtRackN.setEnabled(false);
        pnlEliminarPallet3.add(txtRackN);
        txtRackN.setBounds(170, 70, 140, 28);

        lblUbiNueva.setFont(new java.awt.Font("Dialog", 0, 12));
        lblUbiNueva.setForeground(java.awt.Color.black);
        lblUbiNueva.setText("Columna nueva");
        pnlEliminarPallet3.add(lblUbiNueva);
        lblUbiNueva.setBounds(500, 30, 250, 15);

        txtUbicacionN.setEnabled(false);
        pnlEliminarPallet3.add(txtUbicacionN);
        txtUbicacionN.setBounds(660, 20, 140, 28);

        txtPisoN.setEnabled(false);
        pnlEliminarPallet3.add(txtPisoN);
        txtPisoN.setBounds(660, 60, 140, 28);

        lblPiso.setFont(new java.awt.Font("Dialog", 0, 12));
        lblPiso.setForeground(java.awt.Color.black);
        lblPiso.setText("Piso nuevo");
        pnlEliminarPallet3.add(lblPiso);
        lblPiso.setBounds(500, 70, 130, 15);

        btnGuardar.setBackground(new java.awt.Color(240, 235, 226));
        btnGuardar.setFont(new java.awt.Font("Dialog", 0, 12));
        btnGuardar.setForeground(new java.awt.Color(0, 0, 0));
        btnGuardar.setText("Guardar ");
        btnGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGuardarActionPerformed(evt);
            }
        });
        pnlEliminarPallet3.add(btnGuardar);
        btnGuardar.setBounds(510, 200, 110, 30);

        btnBuscarUbiDisponiles.setBackground(new java.awt.Color(240, 235, 226));
        btnBuscarUbiDisponiles.setFont(new java.awt.Font("Dialog", 0, 12));
        btnBuscarUbiDisponiles.setText("+");
        btnBuscarUbiDisponiles.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarUbiDisponilesActionPerformed(evt);
            }
        });
        pnlEliminarPallet3.add(btnBuscarUbiDisponiles);
        btnBuscarUbiDisponiles.setBounds(320, 30, 30, 27);
        pnlEliminarPallet3.add(dtcFecha2);
        dtcFecha2.setBounds(160, 340, 300, 28);

        lblRackNuevo.setFont(new java.awt.Font("Dialog", 0, 12));
        lblRackNuevo.setForeground(java.awt.Color.black);
        lblRackNuevo.setText("Bloque nuevo");
        pnlEliminarPallet3.add(lblRackNuevo);
        lblRackNuevo.setBounds(40, 80, 220, 15);

        txtMotivo.setColumns(20);
        txtMotivo.setLineWrap(true);
        txtMotivo.setRows(5);
        txtMotivo.setWrapStyleWord(true);
        txtMotivo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtMotivoKeyTyped(evt);
            }
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtMotivoKeyPressed(evt);
            }
        });
        jScrollPane6.setViewportView(txtMotivo);

        pnlEliminarPallet3.add(jScrollPane6);
        jScrollPane6.setBounds(170, 110, 270, 92);

        lblBusqFila.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
        lblBusqFila.setForeground(java.awt.Color.red);
        lblBusqFila.setText("(*)");
        pnlEliminarPallet3.add(lblBusqFila);
        lblBusqFila.setBounds(80, 120, 30, 15);

        add(pnlEliminarPallet3);
        pnlEliminarPallet3.setBounds(50, 290, 850, 250);
    }// </editor-fold>//GEN-END:initComponents

    private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarActionPerformed
        int idRack = -1;
        int idPallet = -1;
        int idUbicacion = -1;
        String motivo = "";
        Date fecha = null;
        int numFila = -1;
        int numPiso = -1;
        int numUbicacion = -1;
        if ( this.txtMotivo.getText().isEmpty() ){
            visualHelper.mostrarMensajeAdvertencia("Debe llenar los campos obligatorios (*).");
        }
        else {
            if(this.txtFilaN.getText().isEmpty() ||this.txtRackN.getText().isEmpty() || this.txtPisoN.getText().isEmpty()
                || this.txtUbicacionN.getText().isEmpty()){
                visualHelper.mostrarMensajeAdvertencia("Debe seleccionar la ubicacion para reubicar el pallet");
            }

            else {
             this.txtMotivo.setEnabled(false);
             String numRack = "";
             numFila = Integer.parseInt(this.txtFilaN.getText());
             numPiso = Integer.parseInt(this.txtPisoN.getText());
             numUbicacion = Integer.parseInt(this.txtUbicacionN.getText());
             numRack = this.txtRackN.getText();
//             fecha = visualHelper.obtenerFechaCalendario(dtcFecha3);
             motivo = this.txtMotivo.getText();
             idPallet = Integer.parseInt(this.txtCodigo.getText());
             String codP = this.txtCodigo.getText();
             blUbicacion blUbicacion = new blUbicacion();
             ArrayList<Integer> estados = new ArrayList<Integer>();
             Date fecHoy = (new blHelper()).dameFechaHoy();
      //         if (fecha.compareTo(fecHoy) == 0) {
  
                  try {
                   estados = blUbicacion.getTipoEstadoInt();
                   blUbicacion.registrarUbi(idubi,idPallet,fecHoy,estados.get(0));
                   blUbicacion.actualizarUbi(ubiAnt, idPallet,estados.get(3),motivo);
                   visualHelper.mostrarMensajeSatisfaccion("El producto ha sido removido");
                   String cad = "B"+String.valueOf(numRack)+"-F"+String.valueOf(numFila)+"-P"+String.valueOf(numPiso)+"-C"+String.valueOf(numUbicacion)+"";
                   (new blLog()).registrarLog(this.usuario.getIdUsuario(), this.usuario.getCargo(), "El pallet con código "+ codP +" fue removido a la ubicacion " + cad);
                   this.txtCodigo.setText("");
                   this.txtPiso.setText("");
                   this.txtUbicacion.setText("");
                   this.txtFila.setText("");
                   this.txtRack.setText("");
                   this.txtPisoN.setText("");
                   this.txtUbicacionN.setText("");
                   this.txtFilaN.setText("");
                   this.txtRackN.setText("");
                   this.txtMotivo.setText("");
//                   this.dtcFecha3.setDateFormatString("");
            
                   this.btnGuardar.setEnabled(false);

                  } catch (Exception ex) {
                     Logger.getLogger(pnfReubicarProducto.class.getName()).log(Level.SEVERE, null, ex);
                   }
             //  }
         //    else {
         //        visualHelper.mostrarMensajeAdvertencia("La fecha ingresada deber ser la de hoy");
           //  }
        }
       }
    }//GEN-LAST:event_btnGuardarActionPerformed

    private void btnLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimpiarActionPerformed
        // TODO add your handling code here:
        this.txtCodigo.setText("");
        this.txtPiso.setText("");
        this.txtUbicacion.setText("");
        this.txtFila.setText("");
        this.txtRack.setText("");

    }//GEN-LAST:event_btnLimpiarActionPerformed

    private void btBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btBuscarActionPerformed
        // TODO add your handling code here:
        blUbicacion bu = new blUbicacion();
        ArrayList<Integer> estados = new ArrayList<Integer>();
        try {
            estados = bu.getTipoEstadoInt();
        } catch (SQLException ex) {
            Logger.getLogger(pnfReubicarProducto.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            if (bu.validarTabla(estados.get(0))) {
                dlgBuscarPallet bPallet = new dlgBuscarPallet(null, true, CONST1);
                bPallet.setVisible(true);
                if (bPallet.getPalletElegido() != null) {
                    int numFila = -1;
                    int numPiso = -1;
                    int numUbicacion = -1;
                    int numRack = -1;
                    int codigo = bPallet.getPalletElegido().getId_Pallet();
                    ubiAnt = bPallet.getUbicacionElegido().getId_ubicacion();
                    this.tipoPallet =bPallet.getUbicacionElegido().getTipo_pallet();
                    this.tipoProd = bPallet.getUbicacionElegido().getTipoProd();
                    numRack = bPallet.getRackElegido().getNumRack();
                    numFila = bPallet.getRackElegido().getNumFila();
                    numPiso = bPallet.getUbicacionElegido().getNumPiso();
                    numUbicacion = bPallet.getUbicacionElegido().getNumUbicacion();
                    this.txtCodigo.setText(String.valueOf(codigo));
                    this.txtFila.setText(String.valueOf(numFila));
                    this.txtPiso.setText(String.valueOf(numPiso));
                    this.txtRack.setText(String.valueOf(numRack));
                    this.txtUbicacion.setText(String.valueOf(numUbicacion));
                    this.btnBuscarUbiDisponiles.setEnabled(true);
                    this.btnGuardar.setEnabled(true);
                }
                bPallet.dispose();
            } else {
                  visualHelper.mostrarMensajeAdvertencia("No se ha ingresado ningun pallet al almacen.");
            }
        } catch (Exception ex) {
            Logger.getLogger(pnfReubicarProducto.class.getName()).log(Level.SEVERE, null, ex);
        }


    }//GEN-LAST:event_btBuscarActionPerformed

    private void rbnRackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbnRackActionPerformed
        // TODO add your handling code here:
        this.rbnProducto.setSelected(false);
}//GEN-LAST:event_rbnRackActionPerformed

    private void rbnProductoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbnProductoActionPerformed
        // TODO add your handling code here:
        this.rbnRack.setSelected(false);
}//GEN-LAST:event_rbnProductoActionPerformed

    private void btnBuscarRackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarRackActionPerformed
        dlgElejirRack dlgElejirRack= new dlgElejirRack(null, true,2);
        dlgElejirRack.setVisible(true);
        if (dlgElejirRack.getRackElegido() != null){
            int codigo = dlgElejirRack.getRackElegido().getId_rack();
            this.txtCodRack.setText(String.valueOf(codigo));
        }
        dlgElejirRack.dispose();
}//GEN-LAST:event_btnBuscarRackActionPerformed

    private void btnBuscarPalletActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarPalletActionPerformed
        dlgBuscarPallet bPallet= new dlgBuscarPallet(null, true,CONST1);
        bPallet.setVisible(true);
        if (bPallet.getPalletElegido() != null){
            int codigo = bPallet.getPalletElegido().getId_Pallet();
            this.txtCodPallet.setText(String.valueOf(codigo));
        }
        bPallet.dispose();
}//GEN-LAST:event_btnBuscarPalletActionPerformed

    private void rbnRack1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbnRack1ActionPerformed
        // TODO add your handling code here:
        this.rbnProducto.setSelected(false);
}//GEN-LAST:event_rbnRack1ActionPerformed

    private void rbnProducto1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbnProducto1ActionPerformed
        // TODO add your handling code here:
        this.rbnRack.setSelected(false);
}//GEN-LAST:event_rbnProducto1ActionPerformed

    private void btnBuscarRack1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarRack1ActionPerformed
        dlgElejirRack dlgElejirRack= new dlgElejirRack(null, true,2);
        dlgElejirRack.setVisible(true);
        if (dlgElejirRack.getRackElegido() != null){
            int codigo = dlgElejirRack.getRackElegido().getId_rack();
            this.txtCodRack.setText(String.valueOf(codigo));
        }
        dlgElejirRack.dispose();
}//GEN-LAST:event_btnBuscarRack1ActionPerformed

    private void btnBuscarPallet1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarPallet1ActionPerformed
        dlgBuscarPallet bPallet= new dlgBuscarPallet(null, true,CONST1);
        bPallet.setVisible(true);
        if (bPallet.getPalletElegido() != null){
            int codigo = bPallet.getPalletElegido().getId_Pallet();
            this.txtCodPallet.setText(String.valueOf(codigo));
        }
        bPallet.dispose();
}//GEN-LAST:event_btnBuscarPallet1ActionPerformed

    private void btnBuscarUbiDisponilesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarUbiDisponilesActionPerformed
     blUbicacion bu = new blUbicacion();
     ArrayList<Integer> estados = new ArrayList<Integer>();
        try {
            estados = bu.getTipoEstadoInt();
        } catch (SQLException ex) {
            ex.printStackTrace();
            Logger.getLogger(pnfReubicarProducto.class.getName()).log(Level.SEVERE, null, ex);
            visualHelper.mostrarMensajeError("Ocurrió un error al obtener los tipos de estados.");
        }
        try {
           if (this.txtFila.getText().isEmpty() == false && this.txtRack.getText().isEmpty() == false &&
               this.txtPiso.getText().isEmpty() == false && this.txtUbicacion.getText().isEmpty() == false) {
            if (bu.validarUbiDisp()) {
                dlgBuscarPallet bPallet = new dlgBuscarPallet(null, true, CONST2,tipoPallet,tipoProd);
                bPallet.setVisible(true);
                this.txtMotivo.setEnabled(true);
                if (bPallet.getRackElegido() != null && bPallet.getUbicacionElegido() != null) {
                    int numFila = -1;
                    int numPiso = -1;
                    int numUbicacion = -1;
                    int numRack = -1;
//                    this.dtcFecha3.setEnabled(true);
                    numRack = bPallet.getRackElegido().getNumRack();
                    numFila = bPallet.getRackElegido().getNumFila();
                    numPiso = bPallet.getUbicacionElegido().getNumPiso();
                    numUbicacion = bPallet.getUbicacionElegido().getNumUbicacion();
                    idubi = bPallet.getUbicacionElegido().getId_ubicacion();
                    this.txtFilaN.setText(String.valueOf(numFila));
                    this.txtPisoN.setText(String.valueOf(numPiso));
                    this.txtRackN.setText(String.valueOf(numRack));
                    this.txtUbicacionN.setText(String.valueOf(numUbicacion));
                }
                bPallet.dispose();
            } else {
                visualHelper.mostrarMensajeAdvertencia("No hay ubicaciones disponibles");
            }
            }
            else {
               visualHelper.mostrarMensajeAdvertencia("Debe elejir la ubicacion a reubicar");
            }
        } catch (Exception ex) {
            Logger.getLogger(pnfReubicarProducto.class.getName()).log(Level.SEVERE, null, ex);
        }
}//GEN-LAST:event_btnBuscarUbiDisponilesActionPerformed

    private void txtMotivoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtMotivoKeyTyped
        // TODO add your handling code here:
        visualHelper.soloDigitosLetrasPuntoComaComilla(evt);
}//GEN-LAST:event_txtMotivoKeyTyped

    private void txtMotivoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtMotivoKeyPressed
        // TODO add your handling code here:
        visualHelper.controlarTamanho_V2(evt,100,this.txtMotivo);
}//GEN-LAST:event_txtMotivoKeyPressed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btBuscar;
    private javax.swing.JButton btnBuscarPallet;
    private javax.swing.JButton btnBuscarPallet1;
    private javax.swing.JButton btnBuscarRack;
    private javax.swing.JButton btnBuscarRack1;
    private javax.swing.JButton btnBuscarUbiDisponiles;
    private javax.swing.JButton btnGuardar;
    private javax.swing.JButton btnLimpiar;
    private com.toedter.calendar.JDateChooser dtcFecha;
    private com.toedter.calendar.JDateChooser dtcFecha1;
    private com.toedter.calendar.JDateChooser dtcFecha2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JLabel lblBusqFila;
    private javax.swing.JLabel lblCodigo;
    private javax.swing.JLabel lblCodigo1;
    private javax.swing.JLabel lblCodigo2;
    private javax.swing.JLabel lblCosto1;
    private javax.swing.JLabel lblCosto2;
    private javax.swing.JLabel lblDescripcion;
    private javax.swing.JLabel lblDescripcion1;
    private javax.swing.JLabel lblFecha;
    private javax.swing.JLabel lblFecha1;
    private javax.swing.JLabel lblFilaNueva;
    private javax.swing.JLabel lblMotivo;
    private javax.swing.JLabel lblPallet;
    private javax.swing.JLabel lblPallet1;
    private javax.swing.JLabel lblPiso;
    private javax.swing.JLabel lblRack;
    private javax.swing.JLabel lblRack1;
    private javax.swing.JLabel lblRackNuevo;
    private javax.swing.JLabel lblUbiNueva;
    private javax.swing.JPanel pnlEliminarPallet;
    private javax.swing.JPanel pnlEliminarPallet1;
    private javax.swing.JPanel pnlEliminarPallet2;
    private javax.swing.JPanel pnlEliminarPallet3;
    private javax.swing.JRadioButton rbnProducto;
    private javax.swing.JRadioButton rbnProducto1;
    private javax.swing.JRadioButton rbnRack;
    private javax.swing.JRadioButton rbnRack1;
    private javax.swing.JTextField txtCodPallet;
    private javax.swing.JTextField txtCodPallet1;
    private javax.swing.JTextField txtCodRack;
    private javax.swing.JTextField txtCodRack1;
    private javax.swing.JTextField txtCodigo;
    private javax.swing.JTextField txtCodigo1;
    private javax.swing.JTextField txtCodigo2;
    private javax.swing.JTextArea txtDescripcion;
    private javax.swing.JTextArea txtDescripcion1;
    private javax.swing.JTextField txtFila;
    private javax.swing.JTextField txtFilaN;
    private javax.swing.JTextArea txtMotivo;
    private javax.swing.JTextField txtPiso;
    private javax.swing.JTextField txtPisoN;
    private javax.swing.JTextField txtRack;
    private javax.swing.JTextField txtRackN;
    private javax.swing.JTextField txtUbicacion;
    private javax.swing.JTextField txtUbicacionN;
    // End of variables declaration//GEN-END:variables

}
